UserName = ['张三','李四','王五']
UserPswd = [123456,123456,654321]
UserTell = [13511111111,13522222222,135333333333]
UserMoney = [123,234,456]
Menu1 = '用户登录'
Menu2 = '注册新账号'
Menu3 = '退出系统'
Menu11 = '查看余额'
Menu12 = '转账'
Menu13 = '存款'
Menu14 = '取款'
Menu15 = '返回上一步'

#登录系统，检测用户账户和密码是否匹配
def LogIn():
    print('请输入相关用户信息登陆系统\n')
    UserLogInCount = 1
    global UserLogInName 
    global UserLogInPswd 
    global UserIndex
    global LoginStatus
    while UserLogInCount <= 3:
        UserLogInName = input('请输入您的用户名（输入q退出）：\t')
        UserLogInCount += 1

        if UserLogInName in UserName:
            UserLogInPswd = int(input('请输入您的密码：\t'))
            UserIndex = UserName.index(UserLogInName)
            
            if UserLogInPswd == UserPswd[UserIndex]:
                LoginStatus = 'OK'
                print('登录成功...\n')
                break
            else:
                LoginStatus = 'NO'
                print('WARNING：密码输入错误，最多有三次机会重新输入')
                
        elif UserLogInName == 'q':
            LoginStatus = 'NO'
            break
        else:
            LoginStatus = 'NO'
            print('用户名不存在')

#注册新账号
def SignUp():
    while True:
        UserSignUpName = input('请输入您要注册的用户名（按q退出）：\t')
        if UserSignUpName in UserName:
            print('账户已存在，请重新输入或返回登录')
            continue
        elif UserSignUpName == 'q':
            break
        else:
            UserSignUpPswd = int(input('请输入密码，只能是数字：\t')) 
            UserSignUpTell = int(input('请输入电话号码：\t'))
            UserName.append(UserSignUpName)
            UserPswd.append(UserSignUpPswd)
            UserTell.append(UserSignUpTell)
            UserMoney.append(0)
            print('注册成功！')
            break

#查看余额
def CheckMoney():
    print('您的余额剩余 {}。'.format(UserMoney[UserIndex]))

#转账
def Transfer():
    TransferStatus = True
    while TransferStatus:
        TransferUser = input('要转到哪个用户？（按q退出）')
        
        if TransferUser in UserName and TransferUser != UserLogInName:
            print('您的余额剩余 {}。'.format(UserMoney[UserIndex]))
            
            while TransferStatus:
                TransferMoney = int(input('要转多少钱？（按0返回上一步）'))
                if 0 < TransferMoney <= UserMoney[UserIndex]:
                    UserMoney[UserIndex] -= TransferMoney
                    TransferUserIndex = UserName.index(TransferUser)
                    UserMoney[TransferUserIndex] += TransferMoney
                    print('转账成功！您的余额剩余 {}。'.format(UserMoney[UserIndex]))
                    TransferStatus = False
                elif TransferMoney == 0:
                    break
                else:
                    print('请输入正确的转账数字：')
                    continue
        elif TransferUser == 'q':
            TransferStatus = False
        else:
            print('用户名不存在，请重新输入')
            continue

#存款
def Deposit():
    while True:
        DepositMoney = int(input('要存多少钱（按0退出）？'))
        if DepositMoney > 0:
            UserMoney[UserIndex] += DepositMoney
        elif DepositMoney < 0:
            print('请输入大于0的数字')
            continue
        else:
            break

#取款
def Withdraw():
    while True:
        WithdrawMoney = int(input('要取多少钱（按0退出）？'))
        if 0 < WithdrawMoney <= UserMoney[UserIndex]:
            UserMoney[UserIndex] -= WithdrawMoney
        elif WithdrawMoney < 0:
            print('请输入大于0的数字')
            continue
        elif WithdrawMoney == 0:
            break
        else:
            print('您的钱不够，请重新输入')
            continue
        
CurrentLogIn = True
while CurrentLogIn:
    print('------欢迎进入ATM系统------\n')
    print('1:{}\n2:{}\n3:{}\n'.format(Menu1,Menu2,Menu3))
    UserChooseMenu = input('请选择功能序号\n\n')
    
    if UserChooseMenu == '1':
        #登录系统
        LogIn()
        
        #执行更多操作
        while LoginStatus == 'OK':
            print('1:{}\n2:{}\n3:{}\n4:{}\n5:{}\n'.format(Menu11,Menu12,Menu13,Menu14,Menu15))
            UserChooseMenu1 = input('请选择操作序号：')
            if UserChooseMenu1 == '1':
                CheckMoney()
            elif UserChooseMenu1 == '2':
                Transfer()
            elif UserChooseMenu1 == '3':
                Deposit()
            elif UserChooseMenu1 == '4':
                Withdraw()
            elif UserChooseMenu1 == '5':
                break
            else:
                print('输入错误，重新输入')
                continue
    
    elif UserChooseMenu == '2':
        #注册用户密码
        SignUp()
    elif UserChooseMenu == '3':
        #退出系统
        break
    else:
        #输入错误，重新输入
        continue

"""
给你增加个小小的要求
UserName = ['张三','李四','王五']
UserPswd = [123456,123456,654321]
UserTell = [13511111111,13522222222,135333333333]
UserMoney = [123,234,456]
Menu1 = '用户登录'
Menu2 = '注册新账号'
Menu3 = '退出系统'
Menu11 = '查看余额'
Menu12 = '转账'
Menu13 = '存款'
Menu14 = '取款'
Menu15 = '返回上一步'
这些写成配置文件试试？
"""
